import _ from 'lodash'

const MODAL = {
  SEND_GOODS: 'SEND_GOODS',
  PREVIEW_CAROUSEL: 'PREVIEW_CAROUSEL'
}

const initialState = {
  sendGoods: {
    show: false,
    order: {}
  },
  previewCarousel: {
    list: [],
    show: false
  }
}

const mutations = {
  [MODAL.SEND_GOODS] (state, payload) {
    state.sendGoods = {
      ...state.sendGoods,
      ...payload
    }
  },
  [MODAL.PREVIEW_CAROUSEL] (state, payload) {
    state.previewCarousel = {
      ...state.previewCarousel,
      ...payload
    }
  }
}

const actions = {
  changeSendGoods ({ commit }, payload) {
    commit(MODAL.SEND_GOODS, payload)
  },
  changeCarousel ({ commit }, payload) {
    commit(MODAL.PREVIEW_CAROUSEL, payload)
  }
}

const getters = {}

export default {
  state: _.cloneDeep(initialState),
  mutations,
  actions,
  getters
}
